CustomPredict ================= 根据置信度(weight)对候选标签(label)进行排序和筛选,以生成最终的预测结果。 输入: - **input** - ``LabelInfo`` 结构体数组的地址。每个结构体包含一个整数 ``label`` 和一个浮点数 ``weight``。 - **input_size** - 输入数组中的元素数量。 - **output_num** - 期望输出的预测结果数量(Top-K 中的 K)。 - **weight_threshold** - 一个浮点数阈值,用于过滤掉置信度过低的预测结果。 - **core_mask** - 核掩码 (仅共享存储版本需要)。 输出: - **output_label** - 存储最终预测标签的整数数组地址。 - **output_weight** - 存储最终预测权重的浮点数数组地址。 支持平台: ``FT78NE`` ``MT7004`` .. note:: - 该算子不区分数据类型,但其处理的 ``LabelInfo`` 结构体具有固定的成员类型(int, float)。 **共享存储版本:** .. c:function:: void custompredict_s(LabelInfo * input, int input_size, int *output_label, float *output_weight, int output_num, float weight_threshold, int core_mask) **C调用示例:** .. code-block:: c :linenos: :emphasize-lines: 14 #include #include "custompredict.h" int main() { LabelInfo *input = (LabelInfo *)0xA0000000; // input in DDR int *output_label = (int *)0xB0000000; // output_label in DDR float *output_weight = (float *)0xC0000000; // output_weight in DDR int input_size = 100; // 假设值 int output_num = 10; float weight_threshold = 0.5f; int core_mask = 0xff; custompredict_s(input, input_size, output_label, output_weight, output_num, weight_threshold, core_mask); return 0; } **私有存储版本:** .. c:function:: void custompredict_p(LabelInfo * input, int input_size, int *output_label, float *output_weight, int output_num, float weight_threshold) **C调用示例:** .. code-block:: c :linenos: :emphasize-lines: 13 #include #include "custompredict.h" int main() { LabelInfo *input = (LabelInfo *)0x10000000; // input in L2 int *output_label = (int *)0x10001000; // output_label in L2 float *output_weight = (float *)0x10002000; // output_weight in L2 int input_size = 100; // 假设值 int output_num = 10; float weight_threshold = 0.5f; custompredict_p(input, input_size, output_label, output_weight, output_num, weight_threshold); return 0; }